﻿using FluentMigrator;

namespace NoteDbGenerator
{
    [Migration(3, "账号流水设计")]
    public class _003_Account : Migration
    {
        public override void Down()
        {
            Delete.Table("acfl_t");
            Delete.Table("acct_t");
        }

        public override void Up()
        {
            Create.Table("acct_t")
                .WithColumn("id").AsCustom("NVARCHAR(4)").PrimaryKey()
                .WithColumn("name").AsCustom("NVARCHAR(20)")
                .WithColumn("description").AsCustom("NVARCHAR(256)")
                .WithColumn("createdate").AsDate()
                .WithColumn("discarded").AsBoolean()
                .WithColumn("DiscardedDate").AsDate().Nullable();

            Create.Table("acfl_t")
                .WithColumn("id").AsInt64().Identity().PrimaryKey()
                .WithColumn("happendate").AsDateTime()
                .WithColumn("accountid").AsCustom("NVARCHAR(4)").ForeignKey("acct_t", "id")
                .WithColumn("toaccountid").AsCustom("NVARCHAR(4)").ForeignKey("acct_t", "id").Nullable()
                .WithColumn("BusinessNo").AsCustom("NVARCHAR(20)")
                .WithColumn("description").AsCustom("NVARCHAR(256)")
                .WithColumn("amount").AsDecimal()
                .WithColumn("leftamount").AsDecimal()
                .WithColumn("flowtype").AsInt32()
                .WithColumn("flowseq").AsInt32();
        }
    }
}
